Skip to content

Conversation

@WendellAdriel
Copy link
Contributor

Summary

  • Supports PUT, PATCH, and DELETE method spoofing
  • Only applies to POST requests for security
  • Case-insensitive method values
  • Preserves all request data
  • Automatic support in x-form component
  • Backward compatible (HEAD→GET fallback preserved)
  • Secure by design (doesn't allow GET spoofing)

Changes

This updates the MatchRouteMiddleware to:

  • Check for a _method parameter in the request body
  • Validate and allow only PUT, PATCH, and DELETE methods for security

This also updates the x-form.view.php component to:

  • Automatically detects when method is PUT, PATCH, or DELETE
  • Render the form with method="POST" for browser compatibility
  • Automatically insert a hidden _method field with the original method value

Examples

If using the <form> HTML tag, you'll need to set the method attribute of the form to POST and add a hidden input with the method you want:

<form action="/books/{{ $book->id }}" method="POST">
    <input type="hidden" name="_method" value="PUT" />
</form>

If you're using the x-form component, it's even easier:

<x-form action="/books/{{ $book->id }}" method="PUT">
</x-form>

This will render the <form> tag, setting the method to POST and automatically inserting a hidden _method input with the value you set.

Fixes #1510

@WendellAdriel
Copy link
Contributor Author

@brendt I'm seeing that one test failed, but when I check, it's not related to these changes, and on my local this specific test that's marked as failed is passing.

@brendt
Copy link
Member

brendt commented Aug 20, 2025

As discussed, let's clean these PRs up and tackle them one by one instead of all at the same time.

@brendt brendt closed this Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update/delete verb routes aren't resolved

2 participants